package service;

import dbutil.Dbconn;
import po.User;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Model {
    private Statement stat;
    private ResultSet rs;
    Dbconn s=new Dbconn();

    public List<User> userSelect(){
        List users=new ArrayList();
        try {
            Connection conn=s.getConnection();
            String sql="select * from sysuser";
            stat=conn.createStatement();
            rs = stat.executeQuery(sql);
            User user;
            while(rs.next()){
                user=new User();
                user.setUserId(rs.getInt("UserId"));
                user.setLoginName(rs.getString("LoginName"));
                user.setLoginPwd(rs.getString("LoginPwd"));
                users.add(user);
            }
        } catch (   Exception e) {
            e.printStackTrace();
        }
        return users;
    }
}

